fun (: 'print-all' ( set ) [
  const (: 'elements' ( that each ) )
  loop [
    ( elements next else [ return ( none ) ] delog .)
  ]
  that
] )


fun (: 'sort' ( set ) [

  const (: 'elements' ( that each ) )
  const (: 'pivot' ( elements next else [ return [] ] ) )
  var (: 'low' [] )
  var (: 'high' [] )

  loop [
    elements next else [ stop ] > ( pivot )
    then [ high ( elements value ) ]
    else [ low ( elements value ) ]
  ]

  sort( low ) ( pivot ) merge( sort( high ) )

] )

const (: 'l' [ 3 2 8 2 5 2 1 2 7 2 4 2 3 ] )

( 'Unsorted list' delog .)
( print-all( l ) .)

( 'Sorted list' delog .)
( print-all( sort( l ) ) .)

